#pragma once
#ifndef SENDFILTER_H
#define SENDFILTER_H

#include <streams.h>


class CInputPin;
class CNetSender;

class CSendFilter : public CBaseFilter
{
public:

	// The only allowed way to create Bouncing balls!
	static CUnknown * WINAPI CreateInstance(LPUNKNOWN lpunk, HRESULT *phr);

	int       GetPinCount(void);
	CBasePin *GetPin(int n);

	//  explicit receiver lock aquisition and release
	void LockReceive ()             { m_crtRecv.Lock () ; }
	void UnlockReceive ()           { m_crtRecv.Unlock () ; }

	STDMETHODIMP Pause ();
	STDMETHODIMP Stop () ;


private:
	CSendFilter(LPUNKNOWN lpunk, HRESULT *phr);
public:
	~CSendFilter(void);
CNetSender* m_pNetSender;
private:
	CInputPin* m_inputPin;
	
	CCritSec m_cStateLock;		//  filter lock
	CCritSec m_crtRecv ;         //  receiver lock;
};

class CInputPin :
	public CBaseInputPin
{
public :

	CInputPin (
		IN  TCHAR *         szName,
		IN  CSendFilter *   pFilter,
		IN  CCritSec *      pLock,
		OUT HRESULT *       pHr,
		IN  LPCWSTR         pszName
		) ;

	~CInputPin () ;

	HRESULT
		GetMediaType (
		IN  int             iPos,
		OUT CMediaType *    pmt
		) ;

	HRESULT
		CheckMediaType (
		IN  const CMediaType *  pmt
		) ;

	STDMETHODIMP
		Receive (
		IN  IMediaSample *
		) ;

	
private:
	LONGLONG m_index;
	CSendFilter * m_sndFilter;
	DataItem m_dataItem;
} ;


#endif